package com.qianfeng.openapi.sdk.client;

import com.qianfeng.openapi.sdk.request.RequestParam;
import com.qianfeng.openapi.sdk.utils.HttpClientUtils;
import com.qianfeng.openapi.sdk.utils.Md5Util;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/6
 * @Time: 下午2:12
 */
public class JDDefaultClient implements  JDClient {
    @Override
    public String execute(String url, RequestParam requestParam) {
        Map<String,String> map = new HashMap<>();
        map.put("method",requestParam.getMethod());
        map.put("appKey",requestParam.getAppKey());//﻿561AC1A8676CFCB0CC61B041AE42ABB8
        map.put("timestamp",requestParam.getTimestamp());//%2
        map.put("param_json",requestParam.getParam_json());
        map.put("token",requestParam.getToken());

        String  sign = Md5Util.md5Signature(map,requestParam.getAppSecret());

        map.put("sign",sign);

        return  HttpClientUtils.doPost(url,map);


    }
}
